import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SpringLayout;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.border.BevelBorder;
import javax.swing.JButton;

/**
 * Doctors and Nurses View Appointment Panel
 * @author ThunderDragon
 * @version 1.0
 */
public class DoctorAndNurseViewAppointmentPanel extends JPanel {
	private JTable AppointmentTable;
	private JTable table;

	/**
	 * Panel for Nurses and Doctors to view appointments.
	 */
	public DoctorAndNurseViewAppointmentPanel() {
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		table = new JTable();
		springLayout.putConstraint(SpringLayout.WEST, table, 54, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, table, 404, SpringLayout.WEST, this);
		table.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
		table.setFont(new Font("Times New Roman", Font.PLAIN, 12));
		table.setFillsViewportHeight(true);
		table.setColumnSelectionAllowed(true);
		table.setCellSelectionEnabled(true);
		table.setSurrendersFocusOnKeystroke(true);
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
			},
			new String[] {
				"Time", "Patient Name", "Reason"
			}
		) {
			Class[] columnTypes = new Class[] {
				String.class, Object.class, Object.class
			};
			public Class getColumnClass(int columnIndex) {
				return columnTypes[columnIndex];
			}
		});
		table.getColumnModel().getColumn(0).setPreferredWidth(80);
		table.getColumnModel().getColumn(1).setPreferredWidth(120);
		table.getColumnModel().getColumn(2).setPreferredWidth(150);
		add(table);
		
		JLabel lblTime = new JLabel("Time");
		springLayout.putConstraint(SpringLayout.NORTH, table, 6, SpringLayout.SOUTH, lblTime);
		springLayout.putConstraint(SpringLayout.SOUTH, table, 166, SpringLayout.SOUTH, lblTime);
		springLayout.putConstraint(SpringLayout.EAST, lblTime, 118, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.WEST, lblTime, 54, SpringLayout.WEST, this);
		add(lblTime);
		
		JLabel lblPatientName = new JLabel("Patient Name");
		springLayout.putConstraint(SpringLayout.WEST, lblPatientName, 28, SpringLayout.EAST, lblTime);
		springLayout.putConstraint(SpringLayout.EAST, lblPatientName, 92, SpringLayout.EAST, lblTime);
		add(lblPatientName);
		
		JLabel lblNewLabel = new JLabel("Reason\r\n");
		springLayout.putConstraint(SpringLayout.WEST, lblNewLabel,
				253, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, lblNewLabel, 311, SpringLayout.WEST, this);
		add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("Upcoming Daily Appointments\r\n");
		springLayout.putConstraint(SpringLayout.NORTH, lblNewLabel, 30, SpringLayout.SOUTH, lblNewLabel_1);
		springLayout.putConstraint(SpringLayout.SOUTH, lblNewLabel, 44, SpringLayout.SOUTH, lblNewLabel_1);
		springLayout.putConstraint(SpringLayout.SOUTH, lblPatientName, 44, SpringLayout.SOUTH, lblNewLabel_1);
		springLayout.putConstraint(SpringLayout.NORTH, lblTime, 33, SpringLayout.SOUTH, lblNewLabel_1);
		springLayout.putConstraint(SpringLayout.SOUTH, lblTime, 47, SpringLayout.SOUTH, lblNewLabel_1);
		springLayout.putConstraint(SpringLayout.NORTH, lblPatientName, 30, SpringLayout.SOUTH, lblNewLabel_1);
		springLayout.putConstraint(SpringLayout.NORTH, lblNewLabel_1, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblNewLabel_1, 90, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, lblNewLabel_1, 342, SpringLayout.WEST, this);
		lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
		add(lblNewLabel_1);
		
	}
	
	/**
	 * Set the time in the table at the corresponding index.
	 * @param time The specified time.
	 * @param index The corresponding index in the table.
	 */
	public void setTime(String time, int index){
		table.setValueAt(time, index, 0);
	}
	/**
	 * Set the patient's name in the table at the corresponding index.
	 * @param patientName The specified name.
	 * @param index The corresponding index in the table.
	 */
	public void setPatientName(String patientName, int index){
		table.setValueAt(patientName, index, 1);
	}
	/**
	 * Set the reason in the table at the corresponding index.
	 * @param reason The specified reason.
	 * @param index The corresponding index in the table.
	 */
	public void setReason(String reason, int index){
		table.setValueAt(reason, index, 2);
	}
}
